<div class="data-cart">
<?php
    $CI=& get_instance();
    $CI->load->model('pages_model');
    $CI->load->library('session');
    if($CI->session->userdata('sp_cart')!=null)
    {
        $sp_cart=$CI->session->userdata('sp_cart');
        $total_product = 0;
        $total_price = 0;
        $list_product = null;
        foreach($sp_cart as $id => $qty)
        {
            $total_product+=$qty;
            $product=$CI->pages_model->get_product_by_id($id);
            if(is_numeric($product['price']))
            {
                $total_price+=$product['price']*$qty;
            }
            $list_product[]=array(
                            'id'=>$product['id'],
                            'alias'=>$product['alias'],
                            'name'=>$product['name'],
                            'image'=>$product['image'],
                            'price'=>$product['price'],
                            'quantity'=>$qty
                            );
        }
        
        echo '<h2>Có <b>'.$total_product.' sản phầm</b> trong giỏ.<br />Tổng tiền: <b>'.format_money($total_price).'</b> </h2>';
        echo '<h3><a title="" href="'.site_url('order').'">Ðặt hàng &amp; Thanh toán</a></h3>';
        foreach($list_product as $item)
        {
            echo '<div class="prd-cart-box">';
            echo '<div class="flleft prd-cart-img">';
            echo '<img alt="" src="'.base_url('data/images').'/'.$item['image'].'" onerror="defaultimg(this)"/>';
            echo '</div>';
            echo '<div class="flleft prd-cart-dt">';
            echo '<a class="widget-btn" onclick="remove_product_cart('.$item['id'].')" title="Xóa sản phẩm khỏi giỏ hàng" href="javascript:void(0);">';
            echo '<img src="'.base_url('images/list_remove_btn.gif').'" error="defaultimg(this)" />';
            echo '</a>';
            echo '<div class="name-prd-cart"><a href="'.base_url('product').'/'.$item['id'].'/'.$item['alias'].'">'.$item['name'].'</a></div>';
            echo '<div><strong>'.$item['quantity'].'</strong> x '.format_money($item['price']).'</div>';
            echo '</div>';
            echo '<div class="clr"></div>';
            echo '</div>';
        }
    }
    else
    {
        echo '<div class="text-shopcart">';
        echo 'Chưa có sản phẩm nào trong giỏ hàng của bạn!';
        echo '</div>';
    }
        
?>
</div> 
                        